import re
from typing import Dict


class Talent(Dict):
    def __init__(self, info_str) -> None:
        self.info = info_str
        self["天赋名称"] = self.__match(r"(?<=\|)天赋名称=(.*?)(?=\n)")
        for i in range(6):
            key = f"天赋{i + 1}星"
            self[key] = self.__match(f"(?<=\|){key}=(.*?)(?=\n)")

    def __match(self, format):
        value = re.search(format, self.info, re.MULTILINE)
        return value.group(1) if value else ""